<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>
            个人信息修改
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="../../../static/back/css/x-admin.css" media="all">
    </head>
    
    <body>
        <div class="x-body">
            <form id="recForm" class="layui-form" onsubmit="return false;">
                {% csrf_token %}
                <input type="hidden" name="userid" value="{{ uobj.uid }}">
                 <div class="layui-form-item layui-form-text">
                    <label for="L_sign" class="layui-form-label">
                        个人宣言
                    </label>
                    <div class="layui-input-block">
                        <textarea placeholder="随便写些什么刷下存在感"  id="L_sign" name="selfSlogo" autocomplete="off"
                        class="layui-textarea" style="height: 80px;">{{ uobj.selfslogo }}</textarea>
                    </div>
                </div>
                 <div class="layui-form-item" id="imgPreview">
                    <div class="layui-input-block">
                        <img id="imgPhoto" src="../../../static/back/{{ uobj.selfphoto }}" class="layui-upload-img" style="width:180px; height:140px" />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">上传图片</label>
                    <div class="layui-input-block">
                        <input id="uploadImg" type="file" name="myFile">
                        <input id="photoUrl" name="PicUrl" type="hidden" value="{{ uobj.selfphoto }}"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">关于我</label>
                    <div class="layui-input-block">
                        <textarea id="taCont" name="aboutMe" placeholder="关于自己的描述信息" class="layui-textarea">
                            {{ uobj.aboutme }}
                        </textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block" style="width:150px;">
                        <button class="layui-btn"  id="btn1">提交保存</button>
                    </div>
                </div>
            </form>
        </div>
        <script src="../../../static/back/lib/layui/layui.js" charset="utf-8">
        </script>
        <script src="../../../static/back/js/x-layui.js" charset="utf-8">
        </script>
        <script>
            layui.use(['form','layer','upload','jquery'], function(){
                    var form=layui.form,
                        layer=layui.layer,
                        upload=layui.upload,
                        $=layui.$;
                    upload.render({
                        elem:'#uploadImg'//绑定元素，指向容器的选择器
                        ,url:'/back/upload'//上传服务器接口
                        ,done:function (res) {
                            //上传完毕回调函数，res  服务器响应的信息
                            if(res.success){
                                $("#imgPreview").css('display','block')  //设置样式
                                $('#imgPhoto').attr('src','../../../static/back/'+res.remark)//设置属性
                                $('#photoUrl').val(res.remark)//在隐藏域中赋值图片上传的绝对路径
                                layer.msg('上传成功')
                            }else{
                                layer.msg(res.message)
                            }
                        }
                    });
                    $('#btn1').click(function () {
                            var url='/back/selfinfo';
                        var param=$('#recForm').serialize()
                        $.post(url,param,function (res) {
                            //res 服务器响应的数据
                            if(res.success){
                                layer.msg('修改成功')
                                parent.layer.close(layer.index);//关闭窗口
                                window.parent.location.reload();//重新加载页面
                            }else{
                                layer.msg(res.message)
                            }
                        },'json')
                        return false;
                        });


                {% comment %}function edit() {
                    var url='/back/selfinfo';
                    var param=$('#frm').serialize()
                    $.post(url,param,function (res) {
                        //res 服务器响应的数据
                        if(res.success){
                            layer.msg('修改成功')
                            parent.layer.close(layer.index);//关闭窗口
                            window.parent.location.reload();//重新加载页面
                        }else{
                            layer.msg(res.message)
                        }
                    },'json')
                    return false;
                }{% endcomment %}
            });
           
        </script>
        
    </body>

</html>